class BlackDeathInput extends PlayerInput;

var(BD_Input) float turnRate;

var bool    bMoveLocked;
var float   HotSpotRadius;
var Rotator currCamRot;
var Vector  oldJoy;

event PlayerInput( float DeltaTime )
{
	local Vector  move, facing, joy;
	local float   moveDeltaAbs;
	local Rotator rot, camRot, playerRot;
		
	super.PlayerInput(DeltaTime);
	/*if(BlackDeathHeroPawn(Pawn).isinState('AttackPushForward'))
	{
		`log(BlackDeathCamera(PlayerCamera).CameraStyle);
		aForward = 0;
		aStrafe = 0;
	}*/
	if(BlackDeathCamera(PlayerCamera).CameraStyle == 'FollowCam' || BlackDeathCamera(PlayerCamera).bCamActor)
	{
		move.X = aStrafe;
		move.Y = aForward;
		move.Z = 0.f;

		facing.x = aForward;
		facing.Y = aStrafe;
		facing.Z = 0.f;

		joy.X = RawJoyRight;
		joy.Y = RawJoyUp;

		moveDeltaAbs = Abs(joy.Y - oldJoy.Y) + Abs(joy.X - oldJoy.X);

		if(!bMoveLocked)
		{
			if(  ( move.X != 0.f || move.Y != 0.f ) && moveDeltaAbs < HotSpotRadius )
				bMoveLocked = true;

			currCamRot = BlackDeathCamera(PlayerCamera).CurrentCamRotation;
			oldJoy = joy;
		}
		else if(aTurn != 0.f || moveDeltaAbs > HotSpotRadius)
		{
			bMoveLocked = false;
			oldJoy = joy;
		}

		playerRot.Yaw = Rotation.Yaw;
		camRot.Yaw = currCamRot.Yaw;
		
		//
		playerRot.Pitch = Rotation.Pitch;
		camRot.Pitch = Rotation.Pitch;
		//

		move = TransformVectorByRotation(camRot, move, true);
		move = TransformVectorByRotation(playerRot, move, false);
		aForward = move.Y;
		aStrafe = move.X;

		facing = TransformVectorByRotation(camRot,facing,false);
		if( move.X != 0.f || move.Y != 0.f )
		{
			rot = RInterpTo( Rotation, Rotator( Normal(facing) ), DeltaTime, turnRate );
			SetRotation(rot);
		}
		else bMoveLocked = false;

		BlackDeathCamera(PlayerCamera).desiredTurn = aTurn;
		BlackDeathCamera(PlayerCamera).desiredLookUp = aLookup;
		aTurn = 0.f;
		aLookup = 0.f;
	}
}

DefaultProperties
{
	bMoveLocked = false
	turnRate = 6.f
	HotSpotRadius = 0.25f

	// This keeps Unreal from messing with rotations
	bLockTurnUntilRelease = true
}